﻿using System;
using FluentAssertions;
using NUnit.Framework;
using SlamCms.Data;

namespace SlamCms.Tests
{
    [TestFixture]
    public class QueryParametersTests
    {
        [Test]
        public void SameQueryParametersMustHaveTheSameHashCode()
        {
            var contentTypeCollection = new ContentTypeCollection();
            var queryParameters = new QueryParameters(contentTypeCollection);
            queryParameters.Parameters.Add("key1", new DateTime(2013, 1, 1));

            var queryParameters2 = new QueryParameters(contentTypeCollection);
            queryParameters2.Parameters.Add("key1", new DateTime(2013, 1, 1));

            queryParameters.GetHashCode().Should().Be(queryParameters2.GetHashCode());
        }

        [Test]
        public void DifferentQueryParametersMustHaveDifferentHashCode()
        {
            var contentTypeCollection = new ContentTypeCollection();
            var queryParameters = new QueryParameters(contentTypeCollection);
            queryParameters.Name = "a";

            var queryParameters2 = new QueryParameters(contentTypeCollection);
            queryParameters2.Name = "b";

            queryParameters.GetHashCode().Should().NotBe(queryParameters2.GetHashCode());
        }
    }
}
